package com.gxm.练习.string;

import cn.hutool.core.date.DateUtil;
import org.junit.Test;

import java.time.LocalDate;
import java.util.*;
import java.util.stream.Stream;

public class Demo1 {

    @Test
    public void test1(){
        String a = "字符串";
        String b = "字符串";
        String c = new String("222");
        String d = new String("222");
        System.out.println(a.equals(b));
        System.out.println(c.equals(d));
        System.out.println(c == b);
        System.out.println(Arrays.asList("1111","2222"));
        String aa = "feildName";
        String[] aas = aa.split("\\|");
        System.out.println(aas[0]);
        String json = "{xxxx:xxx}fg分割URI";
        String[] js = json.split("fg分割");
        System.out.println(js);
    }

    @Test
    public void test2(){
        List<String> list = new ArrayList<>();
        list.add("111");
        list.add("222");
        list.add("333");
        System.out.println(String.join("|",list));
    }

    @Test
    public void test3(){
        String str = "10807";
        System.out.println(str.substring(str.length()-2,str.length()-1));

        Map<String, String> map = new HashMap<>();
        map.put("1","1");
        map.put("2","2");
        //fileryydemo(map);
        System.out.println(map);
    }

    @Test
    public void test4(){
        String a = "123";
        String b = "123";
        Map<String, String > map = new HashMap<>();
        map.put("aa", "123");
        if (a == map.get("aa")) {
            System.out.println("等");
        } else {
            System.out.println("不等");
        }
        System.out.printf(String.valueOf(a != b));
    }

    @Test
    public void test5(){
        String s = "\"http://192.168.31.210:48080/admin-api/infra/file/4/get/ad6dd95e7e857b45c8dfd5f7a5b3f9e3ac12705b90106d15bac89745bd5d0850.png\"";
        String[] ss = s.split("/");
        System.out.println(ss[ss.length-1]);
        System.out.println("\"" + "123" + "\"");
        System.out.println(DateUtil.format(new Date(), "yyyy年MM月dd日"));

    }

    private void fileryydemo(Map<String, String> map){
        map.remove("1");
    }

    @Test
    public void test6(){
        String description = "<p><img src=\"%s\" alt=\"image\" data-href=\"%s\" style=\"\"/></p>";
        System.out.println(String.format(description,"123","123"));
        String str = "123.jpg";
        System.out.println(str.replaceAll("123", ""));
        String[] split = str.replaceAll("123", "").split("\\.");
        System.out.println(split[0]);
    }
}
